﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NHibernate.Mapping.Attributes;
using System.Runtime.Serialization;

namespace VemTransporte.Models.Basica
{
    [DataContract(Namespace="", Name="Horario")]
    [Class(Table = "Horario")]
    public class Horario
    {
        #region Atributos
        private int id = 0;
        private Nullable<DateTime> horaSaida;
        private Nullable<DateTime> horaChegada;
        private Linha _Linha;
        #endregion

        #region Propriedades
        [Id(Name = "Id", Column = "PK_IdHorario")]
        [Generator(1, Class = "native")]
        public virtual int Id
        {
            get { return id; }
            set { id = value; }
        }

        
        [Property(Column = "HOR_Saida", Type = "time")]
        public virtual Nullable<DateTime> HoraSaida
        {
            get { return horaSaida; }
            set { horaSaida = value; }
        }

        [DataMember]
        public virtual string HoraSaidaString
        {
            set
            {
                HoraSaidaString = value;
            }

            get
            {
                return this.horaSaida.Value.ToString("hh:mm:ss");
            }
        }

        [DataMember]
        public virtual string HoraChegadaString
        {
            set
            {
                HoraChegadaString = value;
            }
            get
            {
                return this.horaChegada.Value.ToString("hh:mm:ss");
            }
        }

        [Property(Column = "HOR_Chegada", Type = "time")]
        public virtual Nullable<DateTime> HoraChegada
        {
            get { return horaChegada; }
            set { horaChegada = value; }
        }

        [ManyToOne(Name = "Linha", Column = "FK_IdLinha", ClassType = typeof(Linha))]
        public virtual Linha Linha
        {
            get { return _Linha; }
            set { _Linha = value; }
        }
        #endregion

        #region Contrutores
        public Horario() { }
        #endregion

    }
}